package com.briup.app01.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app01.bean.SalChance;
import com.briup.app01.service.SalChanceService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/chance")
@Api(description="客户信息的管理")
public class SalChanceController {
		   @Autowired
		   private SalChanceService chanceService;
		   @PostMapping("saveOrUpdate")
		   @ApiOperation(value="保存或更新",notes="当id为空时为保存，否则为更新")
	       public String saveOrUpdate(SalChance chance) {
			   chanceService.saveOrUpdate(chance);
			   return "操作成功";
		   }
		   @GetMapping("deleteById")
		   @ApiOperation("根据id删除客户信息")
		   @ApiImplicitParam(name="id",value="客户id",dataType="long",paramType="query",required=true)
		   public String deleteById(long id) {
			   chanceService.deleteById(id);
			   return "删除成功";
		   }
		   @GetMapping("selectById")
		   @ApiOperation("根据id查询客户信息")
		   @ApiImplicitParam(name="id",value="客户id",dataType="long",paramType="query",required=true)
		   public SalChance SalChanceselectById(long id) {
			   return chanceService.selectById(id);
		   }
		   @GetMapping("select")
		   @ApiOperation("多条件查询客户信息")
		   @ApiImplicitParams({@ApiImplicitParam(name="source",value="来源",dataType="String",paramType="query"),
		           @ApiImplicitParam(name="title",value="标记",dataType="String",paramType="query"),
		           @ApiImplicitParam(name="cust_name",value="客户名称",dataType="String",paramType="query"),
		   })
		   public List<SalChance> select(String source,String title,String cust_name){
			   return chanceService.select( source,title,cust_name);
		   }
}
